package etnorservice.etnor_service.controller;

import etnorservice.etnor_service.domain.DeployConfig;

import etnorservice.etnor_service.result.ApiResponse;
import etnorservice.etnor_service.service.DeployService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class DeployController {

    private final DeployService deployService;

    @PostMapping("/deploy/start")
    public ApiResponse<String> startDeploy(@RequestBody DeployConfig config) {
        try {
            System.out.println("========>"+config);
            String deployId = deployService.startDeploy(config);
            return ApiResponse.success(deployId);
        } catch (Exception e) {
            return ApiResponse.error(e.getMessage());
        }
    }
}
